﻿using BMSQ.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BMSQ.Admin.Others.APP
{
    public partial class ModifyAPPVersion :PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    string Ver_ID = Request.Params["id"];
                    ShowInfo(Ver_ID);
                }
            }
        }

        private void ShowInfo(string Ver_ID)
        {
            BLL.APP_Version bll = new BLL.APP_Version();
            Model.APP_Version model = bll.GetModel(Ver_ID);
            this.lblVer_ID.Text = model.Ver_ID;
            this.txtVersion_Number.Text = model.Version_Number;
            this.ddlAPPType.SelectedValue = model.APP_Type.ToString();
            this.txtDownLoad_Path.Text = model.DownLoad_Path;
        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtVersion_Number.Text.Trim().Length == 0)
            {
                strErr += "Version_Number不能为空！\\n";
            }
            if (this.txtDownLoad_Path.Text.Trim().Length == 0)
            {
                strErr += "DownLoad_Path不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string Ver_ID = this.lblVer_ID.Text;
            string Version_Number = this.txtVersion_Number.Text;
            int APP_Type = int.Parse(this.ddlAPPType.SelectedValue);
            string DownLoad_Path = this.txtDownLoad_Path.Text;
            int NewVersion = 1;


            Model.APP_Version model = new BLL.APP_Version().GetModel(Ver_ID);
            model.Version_Number = Version_Number;
            model.APP_Type = APP_Type;
            model.DownLoad_Path = DownLoad_Path;
            model.NewVersion = NewVersion;

            BLL.APP_Version bll = new BLL.APP_Version();
            bll.Update(model);
            MessageBox.ShowAndRedirect(this, "保存成功！", "APPVersionList.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("APPVersionList.aspx");
        }
    }
}